1. Field of the Invention
The present invention relates to an apparatus and a method for stereoscopic image processing which process a pair of images photographed by a stereo camera apparatus and then obtain parallax data as three-dimensional distance information.
2. Description of the Related Art
Generally, image processing by a so-called stereo method is known as an image-based three-dimensional measuring technique. In this stereo method, an object is photographed from different positions with a stereo camera apparatus which is composed of two cameras, a correlation between a pair of images thus photographed is determined, a parallax of the same object in a pair of images is obtained based on the correlation and a distance from the stereo camera apparatus to the object is determined from the parallax of the same object using camera parameters based on the principle of triangulation. The camera parameters are the mounting position and focal length of the stereo camera apparatus, etc.
In the image processing by the stereo method, two image signals from the stereo camera apparatus are overlapped while successively shifting one image signal, and then a position where the two image signals coincide with each other is obtained. Accordingly, it is primarily preferable that only a positional deviation by the parallax exists between the two images. Should there exist another positional deviation caused by an optical distortion, for instance, it would cause a mismatching problem, resulting in a decrease in the accuracy of distance information.
Under these circumstances, the present applicant proposed a technique of performing an electrical adjustment without making any mechanical adjustment as shown in Japanese Patent Unexamined Publication No. Hei. 10-307352. The electrical adjustment is performed by executing an affine transformation according to a deviation of the optical position of the stereo camera apparatus. This technique makes it possible to precisely adjust the optical position of the stereo camera apparatus to such a level that is difficult to achieve by mechanical adjustment. Also the technique makes it possible to easily re-adjust a deviation due to changes under aging phenomena after adjustment.
Correction of an image based on the affine transformation previously proposed by the present applicant is a linear correction which works uniformly on the entire image for prevent deterioration of image quality. However, the correction of the image is not intended to cope with nonlinear deviations, such as variations in lens properties, for instance, the focal length of lenses or distortion of the lenses, or relative variations in the shooting directions of two cameras.
Specifically, a distance distribution obtained should ideally give a flat plane when an object like a wall which is parallel to the baseline of a stereo camera apparatus and located at an equal distance from the stereo camera apparatus is photographed. However, there can arise a problem that an equidistant surface inclines due to an influence of a difference between the focal length of the lens of the camera of a reference side and the focal length of the lens of the camera of a comparison side as shown in FIG. 10. Also, there can arise a problem that the equidistant surface does not form a flat plane due to an influence of the distortion of the lens of the comparison side as shown in FIG. 10. These problems cause a decrease in the accuracy of distance measurement.
This invention has been made in consideration of the aforementioned circumstances. Accordingly, it is an object of the invention to provide an apparatus and a method for stereoscopic image processing which can correct parallax detection errors caused by variations in lens properties or relative variations in shooting directions of two cameras constituting a stereo camera apparatus, and thereby improve the accuracy of distance measurement.
The object can be achieved by a stereoscopic image processing apparatus which comprises: a search unit; a parallax calculating unit; and a parallax correcting unit. The search unit searches a corresponding small region in a comparative image corresponding to a small region in a reference image. The comparative image and the reference image are photographed with a stereo camera apparatus. The parallax calculating unit obtains a parallax data of the small regions. The parallax correcting unit corrects the parallax data based on ratios of view angles. The ratio of view angles is a ratio of a small actual view angle of each predetermined region in the comparative image to an ideal view angle of the each predetermined region when optical position of the stereo camera apparatus is in an ideal state.
In the stereoscopic image processing apparatus of the invention, it is preferable that the parallax correcting unit corrects the parallax data on the basis of the ratio of view angles corresponding to a matching point in the comparative image where the corresponding small region matches with the small region in the reference image, and the ratio of view angles corresponding to an infinite distance corresponding point for the small region.
Further, in the stereoscopic image processing apparatus of the invention, it is preferable that the parallax correcting unit has a correction data table based on the ratio of view angles, and corrects the parallax data in reference to correction data of the correction data table. The correction data table may include a first table to be referenced at matching points in the comparative image where the corresponding small regions match with the small regions in the reference image and a second table to be referenced at infinite distance corresponding points. Correction data of the correction data table, the first table and the second table may be integrated values obtained by integrating the ratio of the view angles from a side edge of the comparative image.
Furthermore, in the above-mentioned stereoscopic image processing apparatus, it is also preferable that the parallax correction unit corrects the parallax data based on integrated values obtained by integrating the ratio of the view angles from a side edge of the comparative image.
The above-mentioned object can be achieved by a stereoscopic image processing method which comprises: searching a corresponding small region in a comparative image corresponding to a small region in a reference image, the comparative image and the reference image being photographed with a stereo camera apparatus; obtaining a parallax data of the small regions; and correcting the parallax data based on a ratio of view angles, the ratio of view angles being a ratio of a small actual view angle of each predetermined region in the comparative image to an ideal view angle of the each predetermined region when optical position of the stereo camera apparatus is in an ideal state.
In the stereoscopic image processing method of the invention, it is preferably advantageous that the step of correcting the parallax corrects the parallax data on the basis of the ratio of view angles corresponding to a matching point in the comparative image where the corresponding small region matches with the small region in the reference image, and the ratio of view angles corresponding to an infinite distance corresponding point.
Further, in the stereoscopic image processing method of the invention, it is advantageous that the step of correcting the parallax comprises: preparing a correction data table based on the ratio of view angles; and correcting the parallax based on correction data of the correction data table. The step of preparing correction data table may prepare a first table to be referenced at matching points in the comparative image where the corresponding small regions match with the small regions in the reference image and a second table to be referenced at infinite distance corresponding points. The step of correction the parallax may prepare the correction data table, the first table and the second table based on integrated values obtained by integrating the ratio of the view angles from a side edge of the comparative image.
Furthermore, in the above-mentioned stereoscopic image processing method, it is also advantageous that the step of correction the parallax corrects the parallax data based on integrated values obtained by integrating the ratio of the view angles from a side edge of the comparative image.